/**
 * Copyright (C) 2011 Audit Logger Project. All rights reserved.
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.auditlogger.api;

/**
 * Defines the type of audit log record that is being generated. 
 * <p>
 * Provides constants for the default set of event types such as, 
 * "AUDIT SUCCESS", "AUDIT FAILURE" and "AUDIT UNSPECIFIED", 
 * but you are free to extend this list or use others if required 
 * by your application, by creating new ones.  
 * 
 * This defines the following types of Log events:
 * 		"AUDIT SUCCESS", "AUDIT FAILURE" and "AUDIT UNSPECIFIED"
 * <br>
 * However, you are free too extend this list or use others.
 *  
 * @author Ravi Sharda
 */
public final class EventType {
	
	public static final EventType EVENT_TYPE_SUCCESS = new EventType( "AUDIT SUCCESS", true);
	public static final EventType EVENT_TYPE_FAILURE = new EventType( "AUDIT FAILURE", false);
	public static final EventType EVENT_TYPE_UNSPECIFIED = new EventType( "AUDIT UNSPECIFIED", null);
	
	private String type;
	private Boolean success = null;
	
	/**
	 * 
	 * @param name
	 * @param newSuccess
	 * @exception IllegalArgumentException 
	 *      If the specified name is null or empty 
	 */
	public EventType (String name, Boolean newSuccess) {
		if (name == null || name.trim().equals("")) {
			throw new IllegalArgumentException ("event name is null or empty");
		}
		this.type = name;
		this.success = newSuccess;
	}
	
	public Boolean isSuccess() {
		return success;
	}
	
    /**
     * Convert the {@code EventType} to a string.
     * @return The event type name.
     */
	@Override
    public String toString() {
		return this.type;
	}
}

